const { GOODS_LIST, GOODS_DETAIL, GOODS_NEW, GOODS_EDIT } = require('./consts')
const { SuccessModel } = require('../model/result')

// 处理商品路由
const goodsRouter = (req, res) => {
  const { method, path } = req
  switch (method) {
    case 'get':
      // 商品列表获取
      if (path === GOODS_LIST) {
        return new SuccessModel({
          message: '商品列表获取成功',
          data: []
        })
        // 商品详情获取
      } else if (path === GOODS_DETAIL) {
        return new SuccessModel({
          message: '商品详情获取成功',
          data: {}
        })
      }
      break
    case 'post':
      // 商品新增
      if (path === GOODS_NEW) {
        return new SuccessModel({
          message: '商品新增成功'
        })
        // 商品编辑
      } else if (path === GOODS_EDIT) {
        return new SuccessModel({
          message: '商品编辑成功'
        })
      }
      break
  }
}

module.exports = goodsRouter
